﻿using ConsoleAlgorithms.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace ConsoleAlgorithms.Tests
{
    public class EX102_Permutation_Combination : ITestable
    {
        List<List<int>> res = new List<List<int>>();

        public void Test()
        {
            int[] arr = { 1, 2, 3 };
            dfs(arr, new List<int>());
            foreach (var re in res)
            {
                Console.WriteLine(ListHelper<int>.ListToString(re));
            }

        }

        public List<List<int>> dfs(int[] arr, List<int> list)
        {
            List<int> temp = new List<int>();
            temp.AddRange(list);
            if (arr.Length == list.Count)
            {
                res.Add(temp);
            }
            for (int i = 0; i < arr.Length; i++)
            {
                if (temp.Contains(arr[i]))
                {
                    continue;
                }
                temp.Add(arr[i]);
                dfs(arr, temp);
                temp.Remove(temp.Count - 1);
            }
            return res;
        }


    }
}
